<template>
    <div>
        <!--轮播图组件-->
        <swiper :datalist="swipeData" :isfull="true"></swiper>
        <!--六宫格区域-->
        <ul class="mui-table-view mui-grid-view mui-grid-9">
            <li v-for="item in sixthDatas" :key="item.id" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                <router-link :to="item.to">
                    <img :src="item.imgUrl">
                    <div class="mui-media-body">{{item.text}}</div>
                </router-link>
            </li>
            <!--<span class="mui-badge">5</span>-->
        </ul>

    </div>
</template>

<script>
    import { Toast } from 'mint-ui';
    import connector from '../../base/interface.js';
    /*导入轮播图组件*/
    import swiper from '../swiper.vue';

    export default {
        name: "home",
        data(){
            return{
                /*轮播图数据*/
                swipeData:[],
                /*六宫格区域数据*/
                sixthDatas:[]
            }
        },
        methods:{
          swipe(){
              /*获取轮播图数据*/
              connector.getSwipeData().then(result=>{
                  result.forEach(item=>{
                      item.url=item.img;
                  });
                  this.swipeData=result;
              },err=>{
                  Toast('加载轮播图失败');
                  console.log(err.message);
              })
          },
           sixth(){
              /*获取六宫格区域数据*/
              connector.getSixthData().then(result=>{
                  this.sixthDatas=result.list;
              },err=>{
                  Toast('加载六宫格区域数据失败');
                  console.log(err.message);
              });
          }
        },created() {
            this.swipe();
            this.sixth();
        },components:{
            swiper
        }
    }
</script>

<style scoped lang="scss">
@import "../../base/baseRem.scss";
.mui-grid-view.mui-grid-9{
    background-color: white;
    li{border: none;}
    img{
        width: 60%;
    }
    .mui-media-body{
        font-size: remFu(13);
    }
}
</style>